<template>
  <a-card :bordered="false">
  <a-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ props: {disabled: disableSubmit} }"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="取消">
    <a-spin :spinning="confirmLoading">
        <a-tab-pane  key="1" :forceRender="true">
          <!-- 查询区域 -->

          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :loading="loading"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            @change="handleTableChange">
            <!-- 字符串超长截取省略号显示-->
            <span slot="fdExpain" slot-scope="text">
          <j-ellipsis :value="text" :length="8" />
        </span>
          </a-table>
        </a-tab-pane>

    </a-spin>
  </a-modal>
  </a-card>
</template>

<script>
  import { httpAction, postAction, getAction } from '@/api/manage'
  import { FormTypes, VALIDATE_NO_PASSED, getRefPromise, validateFormAndTables } from '@/utils/JEditableTableUtil'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JEllipsis from "@/components/jeecg/JEllipsis";


  export default {

    name: 'OpersscArHistoryModal',
    mixins: [JeecgListMixin],
    components: {
      JEllipsis,
    },

    data() {
      return {

        visible: false,
        model: {},
        //编辑信息

          columns: [
            {
              title: '订阅名称',
              align:"center",
              dataIndex: 'fdName',

            },
            {
              title: '订阅说明',
              align:"center",
              dataIndex: 'fdExpain',
              scopedSlots: {customRender: 'fdExpain'},
            },
            {
              title: '是否脱敏',
              align:"center",
              dataIndex: 'fdDes_dictText'
            },
            {
              title: '应用工程',
              align:"center",
              dataIndex: 'fdProject'
            },
            {
              title: '创建时间',
              align:"center",
              dataIndex: 'createTime'
            },


            {
              title: '脱敏目标库',
              align:"center",
              dataIndex: 'fdSource'
            },
            /* {
               title: '申请人',
               align:"center",
               dataIndex: 'fdApplyUser'
             },
             {
               title: '复合人',
               align:"center",
               dataIndex: 'fdCheckUser2'
             },*/

            {
              title: '状态',
              align:"center",
              dataIndex: 'fdStatus_dictText'
            },
            /*   {
                 title: '是否发布到调度平台',
                 align:"center",
                 dataIndex: 'fdRelease_dictText'
               },*/
          ],


        confirmLoading: false,
        selectedRows: [],

        url: {
          list: "/rule/OpersscAr/list",
        }
      }
    },
    created: function() {

    },

    methods: {
      edit(id) {
        this.visible = true;
        this.activeKey = '1'
        this.model = Object.assign({id:id} )
        // 加载子表数据
        /*let para = { id: this.model.id }
        this.requestTableData(this.url.list, param, )*/
        this.loadData()
      },
      /** 查询某个tab的数据 */
     /* requestTableData(url, param) {
        this.loading = true
        getAction(url, param).then(res => {
         this.dataSource = res.result.records
          this.ipagination.total = res.result.total;
        }).finally(() => {
          this. loading = false
        })
      },*/
      //查询某个tab的数据
      loadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        this.loading = true
        var param = this.getQueryParams();
        var params = {pageNo:param.pageNo,pageSize:param.pageSize,id:this.model.id};
        getAction(this.url.list, params).then(res => {
          console.log(params)
          this.dataSource = res.result.records || [];
          this.ipagination.total = res.result.total;
        }).finally(() => {
          this. loading = false
        })
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectedRows;
      },
      handleOk() {
        const that = this;
        let params = { id: this.model.id,fdTableId:this.selectionRows}
        postAction(this.url.add, params).then(res => {
          that.loading = true;
          if (res.success) {
            that.$message.success(res.message);
            that.$emit('ok');
          } else {
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
          that.close();
        })
      },
      handleCancel() {
        this.close()
        this.loadData(1)
      },
      close() {
        this.visible = false
        this.$emit('close')
      },
    }
  }
</script>

<style scoped>

</style>
